import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/PCdaoru/Hello'
import index from '../components/PCdaoru/index'
import xiugai from '../components/PCdaoru/xiugai'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/login',
      name: 'Hello',
      component: Hello
    },
    {
      path: '/index',    
      component: index
    },
    {
      path:'/xiugai',
      component: xiugai
    }
  ]
})
router.beforeEach((to, from, next) => {
  
  if (to.path!="/login") {
    if (sessionStorage.token) {
      next()
      
    }
    else{
      
      next({
        path: '/login'
      });
      
    }
  }else {
    next()
  }
})
export default router